import request from '@/server'

// 获得文字列表
export function getArticleListApi(page: any) {
  return request.get({
    url: '/share/article?page=' + page,
    isLoading: true
  })
}

// 发布文章评论
export interface ArticleCommentType {
  content: string
  article_id: string | number
  username: string
  avatar: string
}
export function addArticleCommentApi(data: ArticleCommentType) {
  return request.post({
    url: '/share/addComment',
    data
  })
}

// 根据文章id获取评论
export interface ArticleCommentListType {
  article_id: string | number
  page: number | string
  size: number
}
export function getArticleCommentApi(
  article_id: string | number,
  page: number | string,
  size: number | string
) {
  return request.get({
    url: `/share/getComment?article_id=${article_id}&page=${page}&size=${size}`
  })
}

// 获得随记列表
export function getLiftRecordApi(page: number | string) {
  return request.get({
    url: '/share/getLiftRecord?page=' + page,
    isLoading: true
  })
}

// 给文章点赞
export function addArticleLikeApi(article_id: string | number) {
  return request.get({
    url: `/share/addLikeArticle?article_id=${article_id}`,
    isLoading: true
  })
}

// 增加文章预览量
export function addArticleViewApi(article_id: string | number) {
  return request.get({
    url: `/share/addViewArticle?article_id=${article_id}`
  })
}
